#include "../protocol_parser.h"
#include <cstdio>
#include <gtest/gtest.h>

void PrintProtocolData(ProtocolParser::ProtocolData & data)
{
    printf("host : %s and port : %d and uri : %s.\n", data.m_host.c_str(), data.m_port, data.m_uri.c_str());
    printf("name : %s and port : %d and tls : %d and protocol type : %d.\n", data.m_protocol.m_protocol_name.c_str(),
           data.m_protocol.m_protocol_port, data.m_protocol.m_use_tls_or_dtls, data.m_protocol.m_protocol_type);
}

TEST(UrlParser, Test)
{
    {
        std::string url  = "https://www.baidu.com/";
        auto        data = ProtocolParser::ParserUrl(url);
        PrintProtocolData(data);
    }
    {
        std::string url  = "https://www.baidu.com/index.html";
        auto        data = ProtocolParser::ParserUrl(url);
        PrintProtocolData(data);
    }
    {
        std::string url  = "https://www.baidu.com:4433/index.html";
        auto        data = ProtocolParser::ParserUrl(url);
        PrintProtocolData(data);
    }
}
